<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css"href="css/style.css"/>
		<script type="text/javascript"src=""></script>
		<title>水果管理系统</title>
	</head>
	<body>
		<h1>水果管理系统</h1>
		<table>
			<tr>
				<td>种类：</td>
				<td>
					<input type="text" name="name"/>
				</td>
			</tr>
			<tr>
				<td>价格：</td>
				<td>
					<input type="text" name="price"/>
				</td>
			</tr>
			<tr>
				<td>功效：</td>
				<td>
					<input type="text" name="gongxiao"/>
				</td>
			</tr>
			<tr>
				<td>产地：</td>
				<td>
					<input type="text" name="chandi"/>
				</td>
			</tr>
		</table>
		<script type="text/javascript">
			let id;
			window.onload=function(){
				id = window.location.search.substring(1).split("=")[1];
				let ajax =getAjax();
				ajax.open("GET","./server/select_server.php?id=" + id,false);
				ajax.send();
				let data = JSON.parse(ajax.responseText);
				document.getElementsByName("name")[0].value = data.name;
				document.getElementsByName("price")[0].value = data.price;
				document.getElementsByName("gongxiao")[0].value = data.gongxiao;
				document.getElementsByName("chandi")[0].value = data.chandi;
			}
			function update(){
				let name = document.getElementsByName("name")[0].value;
				let price = document.getElementsByName("price")[0].value;
				let gongxiao = document.getElementsByName("gongxiao")[0].value;
				let chandi = document.getElementsByName("chandi")[0].value;
				let ajax = getAjax();
				ajax.open("POST","./server/insert_server.php",false);
				ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded;charset = UTF-8");
				ajax.send("id=" + id + "name="+name+"&price="+price+"&gongxiao="+gongxiao"&chandi="+chandi+);
				alert(ajax.responseText);
				window.location.href = "index.php";
				
			}
		</script>
	</body>
</html>
<html>
	<head>
		<meta charset="utf-8">
		<script type="text/javascript" src="js/index.js"></script>
		<link rel="stylesheet" type="text/css" href="../css/style.css"/>
		<title>耳机管理系统</title>
	</head>
	<body>
		<h1>耳机管理系统</h1>
		<table>
			<tr>
				<td>品牌：</td>
				<td>
					<input type="text" name="pinpai"/>
				</td>
			</tr>
			<tr>
				<td>功能:</td>
				<td>
					<input type="text" name="gongneng"/>
				</td>
			</tr>
			<tr>
				<td>款式</td>
				<td>
					<input type="text" name="kuanshi"/>
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<button onclick="update()">修改</button>
				</td>
			</tr>
		</table>
		<script type="text/javascript">
			let id;
			window.onload=function(){
				id = window.location.search.substring(1).split("=")[1];
				let ajax =getAjax();
				ajax.open("GET","./server/select_server.php?id=" + id,false);
				ajax.send();
				let data = JSON.parse(ajax.responseText);
				document.getElementsByName("pinpai")[0].value = data.pinpai;
				document.getElementsByName("gongneng")[0].value = data.gongneng;
				document.getElementsByName("kuanshi")[0].value = data.kuanshi;
			}
			function update(){
				let pinpai = document.getElementsByName("pinpai")[0].value;
				let gongneng = document.getElementsByName("gongneng")[0].value;
				let kuanshi = document.getElementsByName("kuanshi")[0].value;
				let ajax = getAjax();
				ajax.open("POST","./server/insert_server.php",false);
				ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded;charset = UTF-8");
				ajax.send("id=" + id + "pinpai="+name+"&gongneng="+gongneng+"&kuanshi="+kuanshi);
				alert(ajax.responseText);
				window.location.href = "index.php";
				
			}
		</script>
	</body>
</html>
